home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / RTANKEXE.ZIP / PATROL.TXT < prev    next >
Text File  |  1989-05-16  |  6KB  |  171 lines

  1. ;-----------------------------------------------------------
  2. ; PATROL.TXT
  3. ;-----------------------------------------------------------
  4. ; This tank will pick an (x,y) location, and move to it, as
  5. ; quickly as possable. Once there, it will show a little
  6. ; fireworks display.
  7. ;-----------------------------------------------------------
  8. ; There are quicker ways to write this, this is just one of
  9. ; many available.
  10. ;
  11. ; The tank uses AUTOmatic tank movement (which is fast, but
  12. ; not accurate) to get in the general area of the destination.
  13. ; Once there it uses the MOVE command for exact placement, if
  14. ; that is possible (IE: the destination is not covered
  15. ; by an unmovable object like a tree).
  16. ; If the tank gets caught on an unmovable object, it will pick
  17. ; a new location.
  18. ;-----------------------------------------------------------
  19. ; This program shows some advanced tank programming stratagies, so
  20. ; examine it closely, and modify it freely!
  21. ;               - Sandy Walsh, May 16/89
  22. ;-----------------------------------------------------------
  23.  
  24.  
  25. ;---------------------
  26. ; Variable definitions
  27. ;---------------------
  28.  
  29. make x                  ; This is the destination X location
  30. make y                  ; and the destination Y location
  31. make d                  ; Direction required to reach X,Y
  32. make look               ; Response from the scan command. Used to check
  33.                         ; if there is an enemy tank in the direction the
  34.                         ; tank is currently looking.
  35. make bump               ; Counter for how many times we hit an unmoveable object
  36. make count              ; Number of move-loops count
  37. make scrap              ; Junk variable for simple loops, etc
  38.  
  39. ;---------------------
  40. ; Start of program
  41. ;---------------------
  42.  
  43. select 3                ; Select the Cannon as a weapon
  44.  
  45. :align                  ; Make the Tank and the Turrent face the same direction
  46. aim ctdir
  47. jneq ctdir,cgdir,:align
  48. lock 1                  ; Now that they face the same way, lock them together
  49.  
  50. :loop           ;       ->>>- Main Loop ->>>+
  51.                 ;                           |
  52. rand x,100      ;        Pick a Destination |
  53. rand y,70       ;                           V
  54.                 ;                           V
  55. call :getthere  ;        Call subroutine    |
  56.                 ;                           |
  57. call :display   ;        WE'RE HERE!        |
  58.                 ;        Make a display!!   |
  59. goto :loop      ;       --------<<<---------+
  60.  
  61. ;---------------------
  62. ; End of Main program
  63. ;---------------------
  64.  
  65. ;-------------------------------------
  66. :getthere
  67. ;-------------------------------------
  68. ; Move Tank currently at (whereX, whereY) to (X,Y)
  69. ;-------------------------------------
  70. set count,0               ; Reset the loop counter
  71.  
  72. :loop2
  73. auto 0                    ; Start the tank moving automatically
  74. jeq x,wherex,:check       ; Does the X axis match up?? If so go to :check
  75. :nope
  76. auto 1
  77.  
  78. conv x,y,d                ; Convert the destination to a direction from 1-8
  79.  
  80. jeq ctdir,d,:skip1        ; If we don't have to change from our current direction
  81.                           ; Go to :skip1
  82. auto 0
  83. face d
  84.  
  85. add count,1               ; Increase the loop counter by 1
  86. jgt count,8,:FineMove     ; If we have to turn more than 3 times (Which we shouldn't!)
  87.                           ; Go to the "Fine Movement" routine
  88. :skip1
  89. auto 0
  90. jeq blockage,1,:Check_Object  ; If we are blocked by an unmoveable object. Check it out
  91. auto 1
  92. set bump,0                    ; Otherwise, Reset Bump to zero
  93.  
  94. goto :loop2               ; Keep moving towards destination
  95.  
  96. ;---------------------------------------------------------------
  97.  
  98. :check
  99. jneq y,wherey,:nope       ; Does the y-axis also match? If not, go back to loop
  100.                           ; If yes ...
  101. :goback
  102. return                    ; Go back to calling function
  103.  
  104. :Check_Object
  105. add bump,1                ; increase the number of times we hit an
  106.                           ; unmovable object in a row.
  107.  
  108. jlt bump,10,:loop2        ; If not 10 times, go back to movement loop
  109. goto :goback              ; If we hit the object 10 times, go somewhere else.
  110.  
  111. ;----------------------------------------------------------------
  112. :FineMove
  113. ;-------------------------------------
  114. ; Move Tank currently at (whereX, whereY) to (X,Y), using fine movement
  115. ;-------------------------------------
  116.  
  117. auto 0                    ; Automatic tank movement is ALWAYS OFF in fine move
  118.  
  119. :loop3
  120. jeq x,wherex,:check1      ; Does the X axis match up?? If so go to :check1
  121. :nope1
  122.  
  123. conv x,y,d                ; Convert the destination to a direction from 1-8
  124. face d                    ; Desired direction (d)
  125. move                      ; Move a single step in the desired direction.
  126.  
  127. jeq blockage,1,:Check_Object1    ; If we are blocked by an unmoveable object. Check it out
  128. set bump,0                       ; Otherwise, Reset Bump to zero
  129.  
  130. goto :loop3               ; Keep moving towards destination
  131.  
  132. ;---------------------------------------------------------------
  133.  
  134. :check1
  135. jneq y,wherey,:nope1      ; Does the y-axis also match? If not, go back to loop
  136.                           ; If yes ...
  137. goto :goback
  138.  
  139. :Check_Object1
  140. add bump,1                ; increase the number of times we hit an
  141.                           ; unmovable object in a row.
  142.  
  143. jlt bump,10,:loop3        ; If not 10 times, go back to movement loop
  144. goto :goback              ; If we hit the object 10 times, go somewhere else.
  145.  
  146. ;----------------------------------------------
  147. :Display
  148. ;----------------------------------------------
  149. ; This routine simply spins the tank around and shoots all over the place.
  150. ; It is used to show that we have reached our destination.
  151. ; It could, however, do something useful like:
  152. ;       - Radio other tanks of the location
  153. ;       - Sit for a little while, and track other tanks
  154. ;       - Plant mines
  155. ;       - Or all of the above!!
  156. ;----------------------------------------------
  157.  
  158. set scrap,0
  159.  
  160. :dispLoop
  161.  
  162. fire            ; Fire cannon
  163. right           ; Spin clockwise
  164. add scrap,1     ; Increment counter
  165.  
  166. jlt scrap,8,:dispLoop   ; Turn 8 times
  167. return                  ; Go back and do it again!
  168.  
  169. ;-----------------------
  170. ; End of PATROL.TXT
  171. ;-----------------------